//this code converts networks in brite format to format
//nodes: id x y degree_node processing
//edges: id from to bandwidth

#include<cstdio>
#include<cstdlib>
#include<ctime>

int uniform_dist( int min, int max ){
	return (rand()%(max-min+1)+min);
}

char getNodeType(){
	if( rand()%2 )
		return 'A';
	else
		return 'C';
}

int main( int argc, char** argv ){
	
	
	FILE *in, *out;
	in = fopen( argv[1],"r" );
	out = fopen( argv[2],"w" );
	
	int min_proc = atoi( argv[3] );
	int max_proc = atoi( argv[4] );
	int min_band = atoi( argv[5] );
	int max_band = atoi( argv[6] );
	
	char line[100];
	fgets( line, 100, in );
	fgets( line, 100, in );
	
	int nodes;
	int edges;
	int profit;
	sscanf( line, "%d %d", &nodes, &edges );
	fprintf( out, "%d %d", nodes, edges/2 );
	
	sscanf( argv[7], "%d", &profit );
	fprintf( out, " %d\n", profit );
	  	
	fgets( line, 100, in );
	fgets( line, 100, in );
	
	int seed;
	sscanf( argv[8], "%d", &seed );
	srand( seed );
	
	for( int i = 0; i < nodes; ++i ){
  		int id, name, x, y;
   		fgets( line, 100, in );
  		sscanf( line, "%d %d %d %d", &id, &name, &x, &y );
  		fprintf( out, "%d %d %d %d", id, x, y, uniform_dist( min_proc, max_proc ) );
		if( profit >= 0 )
			fprintf( out, " %c\n", getNodeType() );
		else
			fprintf( out, " C\n" );
  	}
	fgets( line, 100, in );
	fgets( line, 100, in );
	
	for( int i = 0; i < edges/2; ++i ){
  		int from, to, length, a;
   		fgets( line, 100, in );
  		sscanf( line, "%d %d %d %d ", &from, &to, &length, &a );
  		fprintf( out, "%d %d %d\n", from, to, uniform_dist( min_band, max_band ) );
  	}
	fclose(in);
	fclose(out);
	
}
